package com.heima.admin.controller.v1;

import com.heima.admin.service.AdChannelService;
import com.heima.model.admin.dtos.ChannelDto;
import com.heima.model.admin.pojos.AdChannel;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/api/v1/channel")
@Api(value = "频道管理接口", description = "频道管理", tags = "channel")
public class AdChannelController {

    @Autowired
    private AdChannelService adChannelService;

    @PostMapping("/list")
    @ApiOperation("频道分页列表查询接口")
    public ResponseResult list(@RequestBody ChannelDto dto){
       return   adChannelService.list(dto);
    }

    @PostMapping("save")
    @ApiOperation("新增频道接口")

    public ResponseResult insert (@RequestBody AdChannel channel){
     return    adChannelService.insert(channel);
    }
    @PostMapping("/update")
    @ApiOperation("更新频道接口")

    public ResponseResult updatess(AdChannel channel){
        return adChannelService.updatessss(channel);
    }

    @GetMapping("/del/{id}")
    @ApiOperation("根据ID删除频道接口")
    public  ResponseResult deleteById(@PathVariable("id")Integer id){
                    return  adChannelService.delete(id);

    }
    @GetMapping("/channels")
    public ResponseResult listAll(){
        return ResponseResult.okResult(adChannelService.list());
    }


}
